<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">/*
 * Copyright (c) 2016 VUI(https://git.oschina.net/durcframework/vui) All rights reserved.
 */

;(function(){

<span id='VUI-Msg'>/**
</span> * 消息提醒框&lt;br&gt;
 * &lt;pre&gt;
function alert1() {
	VUI.Msg.alert('我的消息','这是一个提示信息！');
}

function confirm1() {
	VUI.Msg.confirm('确认对话框', '您想要退出该系统吗？', function(r){
		if (r){
			alert('退出')
		}else{
			alert('不退出')
		}
	});
}
function prompt1() {
	VUI.Msg.prompt('提示信息', '请输入你的姓名：', function(r,msg){
		if(r) {
			alert('你的姓名是：' + msg);
		}
	});

}
 * &lt;/pre&gt;
 * @class VUI.Msg
 * @extends VUI.Dialog
 */
var Msg = VUI.Class('Msg',{
<span id='global-method-constructor'>	/**
</span>	 * @constructor
	 * @ignore
	 */
	init:function(opts) {
		this._super(opts);
	}
},VUI.Dialog);

var msg,alertMsg,$win,callback;
var contentId = '_msgDefWinId_';

<span id='global-method-getMsg'>/**
</span> * @ignore
 */
var getMsg = function() {
	if(!msg) {
		$('body').append($('&lt;div id=&quot;'+contentId+'&quot; style=&quot;min-width:200px;&quot;&gt;&lt;/div&gt;'));
		
		msg = new Msg({
			contentId:contentId
			,onOk:function() {
				callback &amp;&amp; callback(true);
				this.hide();
			}
			,onCancel:function() {
				callback &amp;&amp; callback(false);
				this.hide();
			}
		});
		
		msg.setNextDo(function(){
			this.hideBtn(1);// 隐藏取消按钮
		});
	}
	return msg;
}

<span id='global-property-'>/**
</span> * @ignore
 */
var getWin = function() {
	if(!$win) {
		$win = $('#'+ contentId);
	}
	return $win;
}

<span id='VUI-Msg-static-property-'>/**
</span> * 确认框
 * @static
 */
Msg.confirm = function(title,content,fn) {
	callback = fn;
	getMsg().setTitle(title);
	getWin().html(content || '');
	getMsg().show();
	getMsg().setNextDo(function(){
		this.showBtn(1);
	})
}

<span id='VUI-Msg-static-property-'>/**
</span> * 提醒框
 * @static
 */
Msg.alert = function(title,content,fn) {
	Msg.confirm(title,content,fn);
	getMsg().setNextDo(function(){
		this.hideBtn(1);// 隐藏取消按钮
	});
}

<span id='VUI-Msg-static-property-'>/**
</span> * 文版本提示框
 * @static
 */
Msg.prompt = function(title,content,fn) {
	content = '&lt;div&gt;'+content+'&lt;/div&gt;&lt;div&gt;&lt;input type=&quot;text&quot; style=&quot;width:250px;&quot;/&gt;&lt;/div&gt;';
	Msg.confirm(title,content,function(r){
		var val = getWin().find('input').eq(0).val()
		fn(r,val);
	});
	getWin().width('auto');
}

})();</pre>
</body>
</html>
